package com.company.project.service.impl;

import com.company.project.dao.AuthorsMapper;
import com.company.project.model.Authors;
import com.company.project.model.News;
import com.company.project.service.AuthorsService;
import com.company.project.core.AbstractService;
import com.company.project.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * Created by CodeGenerator on 2018/10/08.
 */
@Service
@Transactional
public class AuthorsServiceImpl extends AbstractService<Authors> implements AuthorsService {
    @Resource
    private AuthorsMapper authorsMapper;

    /**
     * 根据作者名搜索期刊和论文
     * @param cname
     * @param index
     * @return
     */
    @Override
    public PageUtil<Map<Object,Object>> frontendQuery(String cname, Integer index) {
        PageUtil<Map<Object,Object>> pageUtil = new PageUtil();
        pageUtil.setPageSize(15);
        pageUtil.setCpage(index);
        pageUtil.setTotalRow(this.frontendQueryCount(cname));
        List<Map<Object, Object>> maps = authorsMapper.frontendQuery(cname, pageUtil);
        for (int i = 0;i<maps.size();i++){
            maps.get(i).put("value","作者");
        }
        pageUtil.setLists(maps);
        return pageUtil;
    }

    @Override
    public Integer frontendQueryCount(String name) {
        return authorsMapper.frontendQueryCount(name);
    }

    //根据作者id查询稿件
    @Override
    public List selectmanuscript(Integer id) {
        return authorsMapper.selectmanuscript(id);
    }
    //根据id查询评估
    @Override
    public List selectAssessById(Integer id) {
        return authorsMapper.selectAssessById(id);
    }

    @Override
    public Integer InsetsAuthorsList(List<Authors> authorsList) {
        return authorsMapper.insertAuthors(authorsList);
    }


}
